package com.ruyuan.seckilling.activity.request;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import java.util.Date;
import java.util.Objects;

/**
 * @author zhonghuashishan
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ActivitySaveRequest {

    private String activityName;

    private Date showTime;

    private Date startTime;

    private Date endTime;

    public String validateParams() {
        if (StringUtils.isBlank(activityName)) {
            return "活动名称不能为空";
        }
        if (Objects.isNull(showTime) || Objects.isNull(startTime) || Objects.isNull(endTime)) {
            return "未填写活动相关的时间";
        }
        Date now = new Date();
        if (showTime.before(now) || startTime.before(now)) {
            return "展示时间或开始时间不合法";
        }
        return null;
    }
}
